home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group94c.txt
/
000043_mslamm@pluto.mscc.huji.ac.il _Wed Dec 28 20:32:06 1994.msg
< prev
next >
Wrap
Internet Message Format
|
1995-02-09
|
3KB
Received: from optima.CS.Arizona.EDU by cheltenham.CS.Arizona.EDU; Wed, 28 Dec 1994 11:32:20 MST
Received: from pluto.mscc.huji.ac.il by optima.CS.Arizona.EDU (5.65c/15) via SMTP
id AA21911; Wed, 28 Dec 1994 11:32:15 MST
Received: by pluto.mscc.huji.ac.il (AIX 3.2/UCB 5.64/4.03)
id AA50464; Wed, 28 Dec 1994 20:32:06 +0200
Date: Wed, 28 Dec 1994 20:32:06 +0200 (WET)
From: Zvi Lamm <mslamm@pluto.mscc.huji.ac.il>
To: swampler@noao.edu
Cc: icon-group@cs.arizona.edu
Subject: Re: Truth-Table generator
In-Reply-To: <9412281815.AA15224@orpheus.gemini.edu>
Message-Id: <Pine.A32.3.91.941228203008.42611B-100000@pluto.mscc.huji.ac.il>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
On Wed, 28 Dec 1994 swampler@noao.edu wrote:
> > I had a need to write a program to output truth tables for boolean
> > expressions. I used the programmming language J (a sister of APL). The
> > 'program' was about two lines long. I wrote a program for the same task
> > in Icon. I include it below. This Icon solution is ugly (because of the
> > programmer, not the language..), but works. I would be happy to hear
> > comments. Any idea for improvemnet is welcome.
> >
> > I got alot of help on comp.lang.apl when writing the J version - so don't
> > let me down! I think I will write a short note comparing the solutions.
> > My idea is to show the way different languages shape your thought. Both J
> > and Icon are rather special in that they give the programmer tools not
> > found in other languages. Does this interest anyone?
>
> Well, I managed to delete your original program, but here's one that's probably
> similar, using generators rather than vectors. Can it be adapted to your case?
>
> procedure main()
> local t1, t2
>
> every (t1 := (0|1)) & (t2 := (0|1)) do {
> every writes(format ( t1 | t2 | # variables
> "|" | # separator
> iand(t1,t2) | ior(t1,t2) | # functions
> ixor(t1,t2)
> ))
> write()
> }
>
> end
>
> procedure format(t)
>
> # pretty up things for output, the 'wide' field width (5 characters)
> # would let this be used to produce a table header, as in:
> #
> # every writes(format("A" | "B" | "" | "A&B" | "A|B" | "A^B"))
> # write()
> #
> # though the above main program doesn't do so...
> # since this is a one-liner, it could be embedded in place of the call
> # above, but that would be ugly!
>
> return center(map(t, "01", "FT"), 5)
>
> end
>
I rather wanted an all generator solution myself. But the problem is that
my truth tables ma have more than two variables (t1 and t2, above). Now
this makes it a bit harder to do it like this...
Ehud